package com.darling.danotebackend.model.enums;

import cn.hutool.core.util.ObjUtil;
import lombok.Getter;

/**
 * @Author: Darling达
 * @Date: 2025-02-10 2025-02-10
 * @Description: 古之成大事者，不唯有超世之才，亦唯有坚韧不拔之志也！
 */

@Getter
public enum UserRoleEnum {
    
    USER("用户", "user"),
    
    ADMIN("管理员", "admin");
    
    private final String text;
    private final String value;
    
    UserRoleEnum(String text, String value) {
        this.text = text;
        this.value = value;
    }
    
    /**
     * 根据 value 获取枚举
     *
     * @param value 枚举值的value
     * @return 枚举值
     */
    public static UserRoleEnum getEnumByValue(String value) {
        if (ObjUtil.isEmpty(value)) {
            return null;
        }
        for (UserRoleEnum anEnum : UserRoleEnum.values()) {
            if (anEnum.value.equals(value)) {
                return anEnum;
            }
        }
        return null;
    }
    
    
}
